package consultan.vanke.com.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import org.greenrobot.eventbus.EventBus;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import consultan.vanke.com.R;
import consultan.vanke.com.adapter.CommonAdapter;
import consultan.vanke.com.adapter.ViewHolder;
import consultan.vanke.com.bean.HomeJumpBean;
import consultan.vanke.com.constant.ConstantLibrary;
import consultan.vanke.com.event.MessageEvent;
import consultan.vanke.com.listener.OnItemClickListener;
import consultan.vanke.com.utils.SimpleToolbar;

public class MeisFragment extends BaseFragment {
    @BindView(R.id.recy_list)
    RecyclerView recyList;
    @BindView(R.id.simple_toolbar)
    SimpleToolbar simpleToolbar;
    @BindView(R.id.simple_toolbar_main)
    ConstraintLayout simpleToolbarMain;
    private CommonAdapter<String> adapterCenter;
    private List<String> subjectsBeansCenter = new ArrayList<>();


    @Override
    protected void initViews() {
        simpleToolbar.setMainBg(getResources().getColor(R.color.white_color));
        simpleToolbar.setMainTitle("附近美食");
    }

    @Override
    protected void initDatas() {
        for (int i = 0; i < 10; i++) {
            subjectsBeansCenter.add("111");
        }
        recyList.setLayoutManager(new LinearLayoutManager(_mActivity));
        adapterCenter = new CommonAdapter<String>(_mActivity, subjectsBeansCenter, R.layout.meishi_items) {
            @Override
            public void onBindViewHolder(ViewHolder holder, int position) {
                super.onBindViewHolder(holder, position);
            }

            @Override
            public void convert(ViewHolder holder, String assetBean) {
//                ImageView img_photo = holder.getView(R.id.img_photo);

            }

        };
        recyList.setAdapter(adapterCenter);
    }

    @Override
    protected void initEvents() {
        simpleToolbar.setLeftTitleClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pop();
            }
        });
        adapterCenter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@Nullable ViewGroup parent, @Nullable View view, Object o, int position) {
                MessageEvent<HomeJumpBean> messageEvent = new MessageEvent<>();
                messageEvent.setData(new HomeJumpBean(ConstantLibrary.meisdetailfragment, ConstantLibrary.TYPE_TIME_OUT));
                EventBus.getDefault().post(messageEvent);
            }

            @Override
            public boolean onItemLongClick(@Nullable ViewGroup parent, @Nullable View view, Object o, int position) {
                return false;
            }
        });
    }

    @Override
    protected View initContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return View.inflate(_mActivity, R.layout.fangchan_fragment, null);
    }

}
